/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facades;

import entities.Candidate;
import entities.CandidateProfessionalInfo;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author damfercer
 */
@Stateless
public class CandidateProfessionalInfoFacade extends AbstractFacade<CandidateProfessionalInfo> {
    @PersistenceContext(unitName = "ProyectoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CandidateProfessionalInfoFacade() {
        super(CandidateProfessionalInfo.class);
    }
    
    public CandidateProfessionalInfo getBestCandidateProfessionalInfo(Candidate c){
        CandidateProfessionalInfo res=null;
        Query q=em.createNamedQuery("CandidateProfessionalInfo.findBestProfessionalInfoFromCandidate");
        q.setParameter("candidate", c);
        List<CandidateProfessionalInfo> list=q.getResultList();
        if(!list.isEmpty()){
            res=list.get(0);
        }
        return res;
    }
    
}
